//
//  BKXEmoticonKeyboardView.swift
//  微博
//
//  Created by 田凯 on 16/4/24.
//  Copyright © 2016年 田凯. All rights reserved.
//

import UIKit

class BKXEmoticonKeyboardView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //设置 视图
    func setupUI(){
    self.backgroundColor = UIColor.yellowColor()
        //添加控件
        addSubview(emotiontoolBar)
        addSubview(pageView)
        
        //添加约束
        emotiontoolBar.snp_makeConstraints { (make) -> Void in
            make.leading.trailing.bottom.equalTo(self)
            make.height.equalTo(37)
        }
        pageView.snp_makeConstraints { (make) -> Void in
            make.top.leading.trailing.equalTo(self)
            make.bottom.equalTo(emotiontoolBar.snp_top)
        }
        
        
        
        // 执行 点击button的闭包
        emotiontoolBar.buttonClickBag = {[weak self](type: emotionToolBarType) in
//            switch type{
//            case .defaults:
//                print("默认")
//            case .enoji:
//                print("enoji")
//            case .lxh:
//                print("浪小花")
//
//            }
        
            let indexPath = NSIndexPath(forItem: 0, inSection: type.rawValue)
        
            self?.pageView.scrollToItemAtIndexPath(indexPath, atScrollPosition: UICollectionViewScrollPosition.Left, animated: false)
        }
        
    
    }
    // MARK: - 懒加载 表情键盘下的toolbar
    private lazy var emotiontoolBar: BKXEmotionToolBar = {
        let emotion = BKXEmotionToolBar()
        
        
        return emotion
        
        }()
    // MARK: - 懒加载 pageview
    private lazy var pageView : BKXEmotionPageView = {
        let  pageview = BKXEmotionPageView()
        pageview.bounces = false
        pageview.showsVerticalScrollIndicator = false
        pageview.showsHorizontalScrollIndicator = false
        pageview.pagingEnabled = true
        return pageview
        
        
        }()
    
}
